function GM:HUDPaint()
	//this allows us to disable the hud for whatever reason, just set it back to nil from something to show it again.
	if(LocalPlayer().DontDrawHud ~=nil) then return end
	
	self.BaseClass:HUDPaint()
	
	local tr = LocalPlayer():GetEyeTraceNoCursor()
	
	self:PaintMessages()
	DrawMoneyChanges()
	DrawDrugs()
	DrawScans()
	
	//entity specific HUDs
	for k, ent in pairs(ents.GetAll()) do
		if ent.HUDPaint then ent:HUDPaint(tr) end
	end
	
	if tr.Entity:IsPlayer() then
		DrawPlayerInfo(tr)
	end
	
	local r = LocalPlayer():GetInfoNum("rpdm_messages_r")
	local g = LocalPlayer():GetInfoNum("rpdm_messages_g")
	local b = LocalPlayer():GetInfoNum("rpdm_messages_b")
	local a = LocalPlayer():GetInfoNum("rpdm_messages_a")

	local hx = 9
	local hy = ScrH() - 25
	local hw = 190
	local hh = 10
	
	local armor = LocalPlayer():Armor()
	if LocalPlayer():Armor() > 0 then
		draw.RoundedBox(0, hx - 4, hy - 14, 198, 10, Color(r, g, b, a))
		draw.RoundedBox(0, hx, hy-12, 190 * (math.Clamp(armor, 0, 100) / 100), 10, Color(0, 0, 150, 255))
		draw.DrawText(math.ceil(armor), "DefaultSmall", hx + 100, hy - 13, Color(255, 255, 255, 255), 1)
	end
	local health = LocalPlayer():Health()
	draw.RoundedBox(0, hx - 4, hy - 4, hw + 8, hh + 8, Color(r, g, b, a))
	if health > 0 then
		draw.RoundedBox(0, hx, hy, math.Clamp(hw * (health / 100), 0, 190), hh, Color(140, 0, 0, 180))
		draw.DrawText(health, "TargetID", hx + hw / 2, hy - 6, Color(255, 255, 255, 200), 1)
	end
	
	//money and job
	local t = {}
	t.pos	= {hx + 200, hy - 25}
	t.color	= Color(255, 255, 255, 230)
	t.text	= string.format("Job: %s", LocalPlayer():GetNWString("job"))
	t.font	= "TargetID"
	draw.TextShadow(t, 1, 255)
	t.pos	= {hx + 200, hy - 5}
	t.text	= string.format("$%s", util.commas(LocalPlayer():GetDTInt(DT_INT_MONEY)))
	draw.TextShadow(t, 1, 255)

	//==================================
	
	//AFK
	if LocalPlayer():GetAFK() then
		draw.DrawText("You are AFK!", "AFKFont", ScrW()*0.5+3, ScrH()*0.5+3-40, Color(0, 0, 0, afkbigness), 1)
		draw.DrawText("You are AFK!", "AFKFont", ScrW()*0.5, ScrH()*0.5-40, Color(255, 0, 0, afkbigness), 1)
		draw.DrawText("AS LONG AS YOU DON'T MOVE OR SAY ANYTHING\nYOU WILL LOSE MONEY INSTEAD OF GAIN IT!", "ChatFont", ScrW()*0.5+1, ScrH()*0.5+1+60, Color(0, 0, 0, 155), 1)
		draw.DrawText("AS LONG AS YOU DON'T MOVE OR SAY ANYTHING\nYOU WILL LOSE MONEY INSTEAD OF GAIN IT!", "ChatFont", ScrW()*0.5, ScrH()*0.5+60, Color(250, 20, 20, 255), 1)
		local mul = -1
		if !afkdir then
			mul = 1
		end
		
		afkbigness = math.Clamp(afkbigness + (255*FrameTime()*mul), 0, 255)
		if (afkbigness==255 && !afkdir) || (afkbigness==0 && afkdir) then
			afkdir = !afkdir
		end
	end
end

function DrawPlayerInfo(tr)
	if !LocalPlayer():Alive() then return end
	
	local ply = tr.Entity
	local pos = ply:EyePos()
	pos.z = pos.z + 14
	pos = pos:ToScreen()
	
	local t = {}
	
	t.pos		= {pos.x, pos.y}
	t.color		= team.GetColor(ply:Team())
	t.text		= ply:Name()
	t.font		= "TargetID"
	t.xalign	= TEXT_ALIGN_CENTER
	draw.TextShadow(t, 1, 255)
	t.pos		= {pos.x, pos.y + 20}
	t.color		= Color(255, 255, 255, 255)
	t.text		= ply:GetNWString("job")
	draw.TextShadow(t, 1, 255)
	
	if LocalPlayer():GetNWBool("Scannerd") then
		t.pos 	= {pos.x, pos.y + 40}
		t.color = Color(120, 120, 120, 255)
		t.text	= string.format("H: %i A: %i", ply:Health(), ply:Armor())
		draw.TextShadow(t, 1, 255)
		t.pos	= {pos.x, pos.y + 60}
		t.text	= string.format("W: %s", ply:GetActiveWeapon():GetPrintName())
		draw.TextShadow(t, 1, 255)
	end
	if ply:GetNWInt("hitlist") > 0 then
		t.pos 	= {pos.x, pos.y + 40}
		t.color = Color(255, 0, 0, 255)
		t.text	= "Hit target!"
		draw.TextShadow(t, 1, 255)
	end
end

local Scans = {}

function ScannerSweep(msg)
	local ply = msg:ReadEntity()
	local pos = msg:ReadVector()
	local num = msg:ReadShort()
	Scans[num] = {}
	Scans[num].Time = CurTime()+10
	Scans[num].Pos = pos
	Scans[num].Ply = ply
end
usermessage.Hook("RadarScan", ScannerSweep)

function clearscan(index)
	//Msg(player.GetByID(index):GetName().."\n")
	Scans[index] = nil
end

function DrawScans()
	for k, v in pairs(Scans) do
		if v!=nil then
			local ply = v.Ply
			if ValidEntity(ply) then
				local pos = v.Pos + Vector(0,0,100)
				
				pos = pos:ToScreen()
				draw.DrawText(ply:Nick(), "TargetID", pos.x + 1, pos.y + 1, Color(0, 0, 0, 255), 1)
				draw.DrawText(ply:Nick(), "TargetID", pos.x, pos.y, team.GetColor(ply:Team()), 1)
				draw.DrawText("SCAN", "TargetID", pos.x + 1, pos.y-16 + 1, Color(0, 0, 0, 255), 1)
				draw.DrawText("SCAN", "TargetID", pos.x, pos.y-16, Color(255,0,0,255), 1)
			end
			if v.Time<CurTime() then
				clearscan(k)
			end
		end
	end
end

MoneyChanges = {}
function DrawMoneyChanges()
	if !MoneyTrap then
		MoneyTrap = LocalPlayer():GetDTInt(DT_INT_MONEY)
	end
	
	if MoneyTrap != LocalPlayer():GetDTInt(DT_INT_MONEY) then
		table.insert(MoneyChanges, {
			MoneyAlpha = 255, 
			MoneyY = ScrH() - 75, 
			MoneyAmount = LocalPlayer():GetDTInt(DT_INT_MONEY) - MoneyTrap
		})
		MoneyTrap = nil
	end
	
	for k, v in pairs(MoneyChanges) do
		if(v.MoneyAlpha >= 0) then
			if v.MoneyAmount < 0 then
				draw.DrawText(tostring(v.MoneyAmount), "TargetID", 11, v.MoneyY + 1, Color(0, 0, 0, v.MoneyAlpha), 0)
				draw.DrawText(tostring(v.MoneyAmount), "TargetID", 10, v.MoneyY, Color(150, 20, 20, v.MoneyAlpha), 0)
			else
				draw.DrawText("+" .. tostring(v.MoneyAmount), "TargetID", 11, v.MoneyY + 1, Color(0, 0, 0, v.MoneyAlpha), 0)
				draw.DrawText("+" .. tostring(v.MoneyAmount), "TargetID", 10, v.MoneyY, Color(20, 150, 20, v.MoneyAlpha), 0)
			end
			v.MoneyAlpha = math.Clamp(v.MoneyAlpha - (255 * FrameTime()), -1, 255)
			v.MoneyY = v.MoneyY - (50 * FrameTime())
		else
			table.remove(MoneyChanges, k)
		end
	end
	
end

function GM:HUDShouldDraw(name)
	if table.HasValue({"CHudHealth", "CHudBattery", "CHudSuitPower"}, name) then
		return false
	else
		return true
	end
end

function DrawDrugs()
	local x = 7
	local y = ScrH() - 36

	if (LocalPlayer():GetNWBool("Snipe Shieldd")==true) then
		draw.DrawText("p", "DrugFont", x+129, y-49, Color( 0,  0,  0,200), 0)
		draw.DrawText("p", "DrugFont", x+128, y-50, Color(255,255,255,255),0)
	end
	if (LocalPlayer():GetNWBool("Helmetd")==true) then
		draw.DrawText("E", "DrugFont", x+149, y-49, Color( 0,  0,  0,200), 0)
		draw.DrawText("E", "DrugFont", x+148, y-50, Color(255,255,255,255),0)
	end
	if (LocalPlayer():GetNWBool("Scannerd")==true) then
		draw.DrawText("H", "DrugFont", x+132, y-29, Color( 0,  0,  0,200), 0)
		draw.DrawText("H", "DrugFont", x+131, y-30, Color(255,255,255,255),0)
	end
	if (LocalPlayer():GetNWBool("Toolkitd")==true) then
		draw.DrawText("f", "CSDFont", x+149, y-34, Color( 0,  0,  0,200), 0)
		draw.DrawText("f", "CSDFont", x+148, y-35, Color(255,255,255,255),0)
	end
	if (LocalPlayer():GetNWBool("poisoned")==true) then
		draw.DrawText("C", "DrugFont", x+93, y-39, Color(0,0,  0,200), 0)
		draw.DrawText("C", "DrugFont", x+92, y-40, Color(50,250,0,255),0)
	end
	DrawDrugIcons()
	DrugTrails()
end

hook.Add("InitPostEntity", "setdebugglobal", function() drugs = GetDrugTables() end)
function DrawDrugIcons()
	local effects = 0
	local x = 7
	local y = ScrH() - 57
	local effectslots = {}
	
	effectslots[0] = 0
	effectslots[1] = 0
	effectslots[2] = 0
	
	for drugclass, drugtable in pairs(drugs) do
		if LocalPlayer():GetNWBool(drugtable.PrintName .. "d") then
			local offset = 0
			local soffset = 0
			local soffset2 = 0
			if drugtable.PrintName=="Leech" then soffset=-1 soffset2=5 end
			if drugtable.PrintName=="Focus" then soffset=-5 end
			if drugtable.Font == "DrugFont2" then offset = -25 end
			
			draw.DrawText(drugtable.Symbol, drugtable.Font, x+soffset+(effectslots[drugtable.type]*20)-1, y-60+soffset2+(drugtable.type*28)+offset-1, Color(0,0,0,200), 0)
			draw.DrawText(drugtable.Symbol, drugtable.Font, x+soffset+(effectslots[drugtable.type]*20), y-60+soffset2+(drugtable.type*28)+offset, drugtable.Color,0)
			effectslots[drugtable.type] = effectslots[drugtable.type]+1
		end
	end
end

function DrawDrugTrail(color, ent, effect)
	local type = effect or "drug_trail"
	if type==none then return end
	local r = color.r
	local g = color.g
	local b = color.b
	if type=="drug_bolt" then
		local gun = ent:GetActiveWeapon()
		if ValidEntity(gun) then
			local attachpos = gun:GetAttachment(1)
			if attachpos!=nil then
				local effectdata = EffectData()
					effectdata:SetOrigin(attachpos.Pos)
					effectdata:SetStart(Vector(r, g, b))
					effectdata:SetEntity(ent)
					effectdata:SetNormal(ent:GetAimVector())
				util.Effect(effect, effectdata)
			end
		end
	else
		local effectdata = EffectData()
			effectdata:SetOrigin(ent:GetPos())
			effectdata:SetStart(Vector(r, g, b))
			effectdata:SetRadius(64)
			effectdata:SetEntity(ent)
		util.Effect(effect, effectdata)
	end
end

local drawstuff = false
function DrugTrails()
	if drawstuff then
		for i, q in pairs(player.GetAll()) do
			if q!=LocalPlayer() then
				for drugclass, drugtable in pairs(drugs) do
					if q:GetNWBool(drugtable.NWName) == true && math.random(1,5)>4 then
						local type="drug_trail"
						if drugtable.type == 1 then type="drug_glow" end
						if drugtable.type == 2 then type="drug_bolt" end
						DrawDrugTrail(drugtable.Color,q,type)
					end
				end
			end
		end
	end
	drawstuff = !drawstuff
end

//not pleased with the code below
function EndStunStickFlash()
	StunStickFlashAlpha = -1
end

function StunStickFlash()
	if(StunStickFlashAlpha == -1 ) then
		StunStickFlashAlpha = 0
	end
	
	timer.Create(LocalPlayer():EntIndex() .. "StunStickFlashTimer", .3, 1, EndStunStickFlash)
end
usermessage.Hook("StunStickFlash", StunStickFlash)

if(GVGUI) then

	for k, v in pairs(GVGUI) do
		v:Remove()
		GVGUI[k] = nil
	end
end
GVGUI = { }
PanelNumg = 0
//=================================================================

function GM:HUDDrawTargetID()
	return false
end